//
//  View+Extension.swift
//  Swift-Codedase
//
//  Created by xyanl on 2023/7/25.
//

import UIKit

extension UIView {
    
    public var left: CGFloat {
        
        get {
            return self.frame.origin.x
        }
        set{
            var r = self.frame
            r.origin.x = newValue
            self.frame = r
        }
        
    }
    
    
    public var right: CGFloat {
        
        get {
            return self.frame.origin.x + self.frame.size.width
        }
        set{
            
            var r = self.frame
            r.origin.x = newValue - r.size.width
            self.frame = r
        }
        
    }
    
    public var top: CGFloat {
        
        get {
            return self.frame.origin.y
        }
        set{
            
            var r = self.frame
            r.origin.y = newValue
            self.frame = r
        }
        
    }
    
    
    public var bottom: CGFloat {
        
        get {
            return self.frame.origin.y + self.frame.size.height
        }
        set{
            
            var r = self.frame
            r.origin.y = newValue - self.frame.size.height
            self.frame = r
        }
        
    }
    
    public var width: CGFloat {
        
        get {
            return self.frame.size.width
        }
        set{
            var r = self.frame
            r.size.width = newValue
            self.frame = r
        }
        
    }
    
    public var height: CGFloat {
        
        get {
            return self.frame.size.height
        }
        set{
            var r = self.frame
            r.size.height = newValue
            self.frame = r
        }
        
    }
    
    public var size: CGSize{
        
        get {
            return self.frame.size
        }
        set{
            var r = self.frame
            r.size = newValue
            self.frame = r
        }
        
    }
}
